package com.example.myapplication.mine

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import com.example.myapplication.R
import com.example.myapplication.navigation.NavigationManager


@Composable
fun AccountAndSecurityPage(){
    val data = arrayOf("个人信息","退出登陆","账户注销")
    Column {
        NavigationBar()

        LazyColumn(modifier = Modifier.fillMaxWidth().background(Color(0xFFF5F5F6)).padding(top = 20.dp)) {
            items(data.count(), key={index -> index.toString()}) { index ->
                Row(modifier = Modifier.fillMaxWidth()
                    .height(47.dp)
                    .background(Color.White)
                    .border(width = 0.5.dp, color = Color(0xFFEEEEEE))
                    .clickable(enabled = true){
                        println("item was clicked, index is ${index}")
                        when(index) {
                            0 -> NavigationManager.navigate("loginMain")
                            1 -> NavigationManager.navigate("loginMain")
                            2 -> NavigationManager.navigate("loginMain")
                        }
                    }.padding(start = 15.dp, end = 13.dp),
                    verticalAlignment = Alignment.CenterVertically,
                    horizontalArrangement = Arrangement.SpaceBetween,
                ){
                    Text(data[index])
                    Image(painter = painterResource(R.drawable.arrow_right_icon), contentDescription = "", modifier = Modifier.width(16.dp).height(16.dp))
                }
            }
        }
    }
}

//个人信息
@Composable
fun PersonInfoPage(navigation : NavHostController){
    Column {
        Text("PersonInfoPage")
    }
}

//账户注销
@Composable
fun ResignAccountPage(navigation : NavHostController){
    Column {
        Text("ResignAccountPage")
    }
}